require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsVoucherRewardHandler ={};
local this = RedDotsVoucherRewardHandler;

function RedDotsVoucherRewardHandler.init()
    CloseEvent(Config.EventType.VoucherReward,this.update);
    ListenEvent(Config.EventType.VoucherReward,this.update);

    return this;
end

-- 是否有返利可领
function RedDotsVoucherRewardHandler.getFlag()
    local voucherData = logicMgr.CostManager.GetVoucherData();
    if logicMgr.CostManager.GetServerRebateType() == 2 and logicMgr.CostManager.HasVoucherReward() and voucherData ~= nil and voucherData.rewarded == 0 then
        return Config.RedDotsFlagState.Needful;
    end
    return Config.RedDotsFlagState.None;
end


function RedDotsVoucherRewardHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.VoucherReward);
end